import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/* Router Modules */
import componentsRouter from './modules/components'
import chartsRouter from './modules/charts'
import tableRouter from './modules/table'
import nestedRouter from './modules/nested'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  // test
  // { path: '/new-plan-query', url: '/plan-monitor/new-plan-query/index', component: () => import('@/views/plan-monitor/new-plan-query/index'), hidden: true },
  // { path: '/plan-excute-rate', url: '/plan-monitor/plan-excute-rate/index', component: () => import('@/views/plan-monitor/plan-excute-rate/index'), hidden: true },
  // { path: '/production-daily', url: '/production/production-daily/index', component: () => import('@/views/production/production-daily/index'), hidden: true },
  // { path: '/router-log-query', url: '/production/router-log-query/index', component: () => import('@/views/production/router-log-query/index'), hidden: true },
  // { path: '/vehicle-detail-query', url: '/production/vehicle-detail-query/index', component: () => import('@/views/production/vehicle-detail-query/index'), hidden: true },
  // { path: '/welding-monitor', url: '/PMC/welding-monitor/index', component: () => import('@/views/PMC/welding-monitor/index'), hidden: true },
  // { path: '/assembly-monitor', url: '/PMC/assembly-monitor/index', component: () => import('@/views/PMC/assembly-monitor/index'), hidden: true },
  // {
  //   path: '/redirect',
  //   component: Layout,
  //   hidden: true,
  //   children: [
  //     {
  //       path: '/redirect/:path*',
  //       component: () => import('@/views/redirect/index')
  //     }
  //   ]
  // },
  
  // {
  //   path: '/auth-redirect',
  //   component: () => import('@/views/login/auth-redirect'),
  //   hidden: true
  // },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/login-for-keyparts',
    component: () => import('@/views/mes-web/login-for-keyparts/index'),
    hidden: true
  },
  {
    path: '/login-for-reviewparts',
    component: () => import('@/views/mes-web/login-for-reviewparts/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    hidden: true,
    children: [
      {
        path: 'home',
        component: () => import('@/views/home/index'),
        name: 'Home',
        meta: { title: 'Home', icon: 'Demo' }
      }
    ]
  },
  // {
  //   path: '/excel',
  //   component: Layout,
  //   redirect: '/excel/export-excel',
  //   name: 'Excel',
  //   meta: {
  //     title: 'Excel',
  //     icon: 'excel'
  //   },
  //   children: [
  //     {
  //       path: 'export-excel',
  //       component: () => import('@/views/excel/export-excel'),
  //       name: 'ExportExcel',
  //       meta: { title: 'Export Excel' }
  //     },
  //     {
  //       path: 'export-selected-excel',
  //       component: () => import('@/views/excel/select-excel'),
  //       name: 'SelectExcel',
  //       meta: { title: 'Export Selected' }
  //     },
  //     {
  //       path: 'export-merge-header',
  //       component: () => import('@/views/excel/merge-header'),
  //       name: 'MergeHeader',
  //       meta: { title: 'Merge Header' }
  //     },
  //     {
  //       path: 'upload-excel',
  //       component: () => import('@/views/excel/upload-excel'),
  //       name: 'UploadExcel',
  //       meta: { title: 'Upload Excel' }
  //     }
  //   ]
  // },
  // {
  //   path: '/documentation',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/documentation/index'),
  //       name: 'Documentation',
  //       meta: { title: 'Documentation', icon: 'documentation', affix: true }
  //     }
  //   ]
  // },
  // {
  //   path: '/guide',
  //   component: Layout,
  //   redirect: '/guide/index',
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/guide/index'),
  //       name: 'Guide',
  //       meta: { title: 'Guide', icon: 'guide', noCache: true }
  //     }
  //   ]
  // },
  // {
  //   path: '/profile',
  //   component: Layout,
  //   redirect: '/profile/index',
  //   hidden: true,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/profile/index'),
  //       name: 'Profile',
  //       meta: { title: 'Profile', icon: 'user', noCache: true }
  //     }
  //   ]
  // }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  {
    path: '/permission',
    component: Layout,
    redirect: '/permission/page',
    // alwaysShow: true, // will always show the root menu
    name: 'Permission',
    meta: {
      title: 'Permission',
      icon: 'lock',
      roles: ['admin', 'editor'] // you can set roles in root nav
    },
    children: [
      {
        path: 'page',
        component: () => import('@/views/permission/page'),
        name: 'PagePermission',
        meta: {
          title: 'Page Permission',
          roles: ['admin'] // or you can only set roles in sub nav
        }
      },
      {
        path: 'directive',
        component: () => import('@/views/permission/directive'),
        name: 'DirectivePermission',
        meta: {
          title: 'Directive Permission'
          // if do not set roles, means: this page does not require permission
        }
      },
      {
        path: 'role',
        component: () => import('@/views/permission/role'),
        name: 'RolePermission',
        meta: {
          title: 'Role Permission',
          roles: ['admin']
        }
      }
    ]
  },

  {
    path: '/icon',
    component: Layout,
    children: [
      {
        path: 'index',
        component: () => import('@/views/icons/index'),
        name: 'Icons',
        meta: { title: 'Icons', icon: 'icon', noCache: true }
      }
    ]
  },

  /** when your routing map is too long, you can split it into small modules **/
  componentsRouter,
  chartsRouter,
  // nestedRouter,
  tableRouter,

  // {
  //   path: '/example',
  //   component: Layout,
  //   redirect: '/example/list',
  //   name: 'Example',
  //   meta: {
  //     title: 'Example',
  //     icon: 'example'
  //   },
  //   children: [
  //     {
  //       path: 'create',
  //       component: () => import('@/views/example/create'),
  //       name: 'CreateArticle',
  //       meta: { title: 'Create Article', icon: 'edit' }
  //     },
  //     {
  //       path: 'edit/:id(\\d+)',
  //       component: () => import('@/views/example/edit'),
  //       name: 'EditArticle',
  //       meta: { title: 'Edit Article', noCache: true, activeMenu: '/example/list' },
  //       hidden: true
  //     },
  //     {
  //       path: 'list',
  //       component: () => import('@/views/example/list'),
  //       name: 'ArticleList',
  //       meta: { title: 'Article List', icon: 'list' }
  //     }
  //   ]
  // },

  // {
  //   path: '/tab',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/tab/index'),
  //       name: 'Tab',
  //       meta: { title: 'Tab', icon: 'tab' }
  //     }
  //   ]
  // },

  {
    path: '/error',
    component: Layout,
    redirect: 'noRedirect',
    name: 'ErrorPages',
    meta: {
      title: 'Error Pages',
      icon: '404'
    },
    children: [
      {
        path: '401',
        component: () => import('@/views/error-page/401'),
        name: 'Page401',
        meta: { title: '401', noCache: true }
      },
      {
        path: '404',
        component: () => import('@/views/error-page/404'),
        name: 'Page404',
        meta: { title: '404', noCache: true }
      }
    ]
  },

  {
    path: '/error-log',
    component: Layout,
    children: [
      {
        path: 'log',
        component: () => import('@/views/error-log/index'),
        name: 'ErrorLog',
        meta: { title: 'Error Log', icon: 'bug' }
      }
    ]
  },

  {
    path: '/excel',
    component: Layout,
    redirect: '/excel/export-excel',
    name: 'Excel',
    meta: {
      title: 'Excel',
      icon: 'excel'
    },
    children: [
      {
        path: 'export-excel',
        component: () => import('@/views/excel/export-excel'),
        name: 'ExportExcel',
        meta: { title: 'Export Excel' }
      },
      {
        path: 'export-selected-excel',
        component: () => import('@/views/excel/select-excel'),
        name: 'SelectExcel',
        meta: { title: 'Export Selected' }
      },
      {
        path: 'export-merge-header',
        component: () => import('@/views/excel/merge-header'),
        name: 'MergeHeader',
        meta: { title: 'Merge Header' }
      },
      {
        path: 'upload-excel',
        component: () => import('@/views/excel/upload-excel'),
        name: 'UploadExcel',
        meta: { title: 'Upload Excel' }
      }
    ]
  },

  // {
  //   path: '/zip',
  //   component: Layout,
  //   redirect: '/zip/download',
  //   // alwaysShow: true,
  //   name: 'Zip',
  //   meta: { title: 'Zip', icon: 'zip' },
  //   children: [
  //     {
  //       path: 'download',
  //       component: () => import('@/views/zip/index'),
  //       name: 'ExportZip',
  //       meta: { title: 'Export Zip' }
  //     },
  //     {
  //       path: 'index',
  //       component: () => import('@/views/pdf/index'),
  //       name: 'PDF',
  //       meta: { title: 'PDF', icon: 'pdf' }
  //     }
  //   ]
  // },

  // {
  //   path: '/pdf',
  //   component: Layout,
  //   redirect: '/pdf/index',
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/pdf/index'),
  //       name: 'PDF',
  //       meta: { title: 'PDF', icon: 'pdf' }
  //     }
  //   ]
  // },
  // {
  //   path: '/pdf/download',
  //   component: () => import('@/views/pdf/download'),
  //   hidden: true
  // },

  // {
  //   path: '/theme',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/theme/index'),
  //       name: 'Theme',
  //       meta: { title: 'Theme', icon: 'theme' }
  //     }
  //   ]
  // },

  // {
  //   path: '/clipboard',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/clipboard/index'),
  //       name: 'ClipboardDemo',
  //       meta: { title: 'Clipboard', icon: 'clipboard' }
  //     }
  //   ]
  // },

  // {
  //   path: 'external-link',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'https://github.com/PanJiaChen/vue-element-admin',
  //       meta: { title: 'External Link', icon: 'link' }
  //     }
  //   ]
  // },
  // 新增 alwaysShow生成菜单时有逻辑判断，只有一个子菜单时隐藏父菜单alwaysShow：true时始终显示
  // {
  //   path: '/bdc',
  //   component: Layout,
  //   redirect: '/bdc/manual-operate',
  //   alwaysShow: true,
  //   meta: { title: 'BDC', icon: 'shopping', roles: ['admin','editor'] },
  //   children: [
  //     {
  //       path: 'manual-operate',
  //       component: () => import('@/views/bdc/manual-operate/index'),
  //       url: '/bdc/manual-operate/index',
  //       name: 'ManualOperate',
  //       meta: { title: '报表demo页', roles: ['admin']}
  //     },
  //     {
  //       path: 'route-mode-ctrl',
  //       component: () => import('@/views/bdc/route-mode-ctrl/index'),
  //       url: '/bdc/route-mode-ctrl/index',
  //       name: 'RouteModeCtrl',
  //       meta: { title: '手动路由控制', roles: ['admin'] }
  //     },
  //     {
  //       path: 'startup-rate-monitor',
  //       component: () => import('@/views/bdc/startup-rate-monitor/index'),
  //       url: '/bdc/startup-rate-monitor/index',
  //       name: 'StartupRateMonitor',
  //       meta: { title: '开动率监控', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'order-rule',
  //       component: () => import('@/views/bdc/order-rule/index'),
  //       url: '/bdc/order-rule/index',
  //       name: 'OrderRule',
  //       meta: { title: '进涂装排序规则', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'line-monitor',
  //       component: () => import('@/views/bdc/line-monitor/index'),
  //       url: '/bdc/line-monitor/index',
  //       name: 'LineMonitor',
  //       meta: { title: '生产线监控', roles: ['admin'] }
  //     },
  //     {
  //       path: 'painting-workshop-monitor',
  //       component: () => import('@/views/bdc/painting-workshop-monitor/index'),
  //       url: '/bdc/painting-workshop-monitor/index',
  //       name: 'PaintingWorkshopMonitor',
  //       meta: { title: '涂装产线监控', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'assemble-workshop-monitor',
  //       component: () => import('@/views/bdc/assemble-workshop-monitor/index'),
  //       url: '/bdc/assemble-workshop-monitor/index',
  //       name: 'AssembleWorkshopMonitor',
  //       meta: { title: '总装产线监控', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'welding-workshop-monitor',
  //       component: () => import('@/views/bdc/welding-workshop-monitor/index'),
  //       url: '/bdc/welding-workshop-monitor/index',
  //       name: 'WeldingWorkshopMonitor',
  //       meta: { title: '焊装产线监控', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'bdc-monitor',
  //       component: () => import('@/views/bdc/bdc-monitor/index'),
  //       url: '/bdc/bdc-monitor/index',
  //       name: 'BdcMonitor',
  //       meta: { title: 'BDC监控', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'workshop-carbody-monitor',
  //       component: () => import('@/views/bdc/workshop-carbody-monitor/index'),
  //       url: '/bdc/workshop-carbody-monitor/index',
  //       name: 'WorkshopCarbodyMonitor',
  //       meta: { title: '车身数量监控', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'pack-workshop-monitor',
  //       component: () => import('@/views/bdc/pack-workshop-monitor/index'),
  //       url: '/bdc/pack-workshop-monitor/index',
  //       name: 'PackWorkshopMonitor',
  //       meta: { title: 'PACK车间产线监控', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'stamping-workshop-monitor',
  //       component: () => import('@/views/bdc/stamping-workshop-monitor/index'),
  //       url: '/bdc/stamping-workshop-monitor/index',
  //       name: 'StampingWorkshopMonitor',
  //       meta: { title: '冲压车间产线监控', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'hold-monitor',
  //       component: () => import('@/views/bdc/hold-monitor/index'),
  //       url: '/bdc/hold-monitor/index',
  //       name: 'HoldMonitor',
  //       meta: { title: 'HOLD记录查询', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'route-log',
  //       component: () => import('@/views/bdc/route-log/index'),
  //       url: '/bdc/route-log/index',
  //       name: 'RouteLog',
  //       meta: { title: '路由日志', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'startup-rate-query',
  //       component: () => import('@/views/bdc/startup-rate-query/index'),
  //       url: '/bdc/startup-rate-query/index',
  //       name: 'StartupRateQuery',
  //       meta: { title: '开动率查询', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'daily-output-chart',
  //       component: () => import('@/views/bdc/daily-output-chart/index'),
  //       url: '/bdc/daily-output-chart/index',
  //       name: 'DailyOutputChart',
  //       meta: { title: '车间日产量报表', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'weekly-output-chart',
  //       component: () => import('@/views/bdc/weekly-output-chart/index'),
  //       url: '/bdc/weekly-output-chart/index',
  //       name: 'WeeklyOutputChart',
  //       meta: { title: '车间周产量报表', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'monthly-output-chart',
  //       component: () => import('@/views/bdc/monthly-output-chart/index'),
  //       url: '/bdc/monthly-output-chart/index',
  //       name: 'MonthlyOutputChart',
  //       meta: { title: '车间月产量报表', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'daily-jph-chart',
  //       component: () => import('@/views/bdc/daily-jph-chart/index'),
  //       url: '/bdc/daily-jph-chart/index',
  //       name: 'DailyJphChart',
  //       meta: { title: 'JPH小时推移表', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'monthly-hpv-effect-chart',
  //       component: () => import('@/views/bdc/monthly-hpv-effect-chart/index'),
  //       url: '/bdc/monthly-hpv-effect-chart/index',
  //       name: 'MonthlyHpvEffectChart',
  //       meta: { title: '月HPV影响报表', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'plan-execute-chart',
  //       component: () => import('@/views/bdc/plan-execute-chart/index'),
  //       url: '/bdc/plan-execute-chart/index',
  //       name: 'PlanExecuteChart',
  //       meta: { title: '计划执行完成报表', roles: ['admin','editor'] }
  //     },
  //     {
  //       path: 'plan-query',
  //       component: () => import('@/views/bdc/plan-query/index'),
  //       url: '/bdc/plan-query/index',
  //       name: 'PlanQuery',
  //       meta: { title: '计划报表', roles: ['admin','editor'] }
  //     }
  //   ]
  // },
  // {
  //   path: '/mes-web',
  //   alwaysShow: true,
  //   component: Layout,
  //   meta: { title: 'MesWeb', icon: 'edit' },
  //   children: [
  //     {
  //       path: 'keyparts-scan',
  //       component: () => import('@/views/mes-web/keyparts-scan/index'),
  //       url: '/mes-web/keyparts-scan/index',
  //       name: 'KeypartsScan',
  //       meta: { title: '关键件扫描', icon: 'bug' }
  //     },
  //     // {
  //     //   path: 'one-car-one-gear',
  //     //   component: () => import('@/views/mes-web/one-car-one-gear/index'),
  //     //   url: '/mes-web/one-car-one-gear/index',
  //     //   name: 'OneCarOneGear',
  //     //   meta: { title: '一车一档' }
  //     // }
  //   ]
  // },
  {
    path: '/efficiency-monitor',
    alwaysShow: true,
    component: Layout,
    meta: { title: '效率', icon: 'excel' },
    children: [
      {
        path: 'daily-jph-chart',
        component: () => import('@/views/efficiency-monitor/daily-jph-chart/index'),
        url: '/efficiency-monitor/daily-jph-chart/index',
        name: 'DailyJphChart',
        meta: { title: 'JPH小时推移表' }
      },
      {
        path: 'monthly-hpv-effect-chart',
        component: () => import('@/views/efficiency-monitor/monthly-hpv-effect-chart/index'),
        url: '/efficiency-monitor/monthly-hpv-effect-chart/index',
        name: 'MonthlyHpvEffectChart',
        meta: { title: '月HPV影响报表' }
      },
      {
        path: 'line-monitor-table',
        component: () => import('@/views/efficiency-monitor/line-monitor-table/index'),
        url: '/efficiency-monitor/line-monitor-table/index',
        name: 'LineMonitorTable',
        meta: { title: '车间生产监控' }
      }
    ]
  },
  {
    path: '/plan-monitor',
    alwaysShow: true,
    component: Layout,
    meta: { title: '计划', icon: 'pdf' },
    children: [
      // {
      //   path: 'plan-execute-chart',
      //   component: () => import('@/views/plan-monitor/plan-execute-chart/index'),
      //   url: '/plan-monitor/plan-execute-chart/index',
      //   name: 'PlanExecuteChart',
      //   meta: { title: '计划执行完成报表' }
      // },
      // {
      //   path: 'plan-query',
      //   component: () => import('@/views/plan-monitor/plan-query/index'),
      //   url: '/plan-monitor/plan-query/index',
      //   name: 'PlanQuery',
      //   meta: { title: '计划报表' }
      // },
      {
        path: 'plan-excute-rate',
        component: () => import('@/views/plan-monitor/plan-excute-rate/index'),
        url: '/plan-monitor/plan-excute-rate/index',
        name: 'PlanExcuteRate',
        meta: { title: '计划执行' }
      },
      {
        path: 'new-plan-query',
        component: () => import('@/views/plan-monitor/new-plan-query/index'),
        url: '/plan-monitor/new-plan-query/index',
        name: 'NewPlanQuery',
        meta: { title: '计划查询' }
      }
    ]
  },
  {
    path: '/process-monitor',
    alwaysShow: true,
    component: Layout,
    meta: { title: '过程跟踪', icon: 'example' },
    children: [
      {
        path: 'hold-monitor',
        component: () => import('@/views/process-monitor/hold-monitor/index'),
        url: '/process-monitor/hold-monitor/index',
        name: 'HoldMonitor',
        meta: { title: 'HOLD记录查询' }
      },
      {
        path: 'route-log',
        component: () => import('@/views/process-monitor/route-log/index'),
        url: '/process-monitor/route-log/index',
        name: 'RouteLog',
        meta: { title: 'BDC路由日志' }
      },
      {
        path: 'startup-rate-query',
        component: () => import('@/views/process-monitor/startup-rate-query/index'),
        url: '/process-monitor/startup-rate-query/index',
        name: 'StartupRateQuery',
        meta: { title: '开动率查询' }
      },
      {
        path: 'line-stop-query',
        component: () => import('@/views/process-monitor/line-stop-query/index'),
        url: '/process-monitor/line-stop-query/index',
        name: 'LineStopQuery',
        meta: { title: '产线停线记录' }
      },
      {
        path: 'daily-line-stop-query',
        component: () => import('@/views/process-monitor/daily-line-stop-query/index'),
        url: '/process-monitor/daily-line-stop-query/index',
        name: 'DailyLineStopQuery',
        meta: { title: '产线日停线统计' }
      }
    ]
  },
  {
    path: '/production-monitor',
    alwaysShow: true,
    component: Layout,
    meta: { title: '生产实绩', icon: 'chart' },
    children: [
      {
        path: 'daily-output-chart',
        component: () => import('@/views/production-monitor/daily-output-chart/index'),
        url: '/production-monitor/daily-output-chart/index',
        name: 'DailyOutputChart',
        meta: { title: '车间日产量报表' }
      },
      {
        path: 'monthly-output-chart',
        component: () => import('@/views/production-monitor/monthly-output-chart/index'),
        url: '/production-monitor/monthly-output-chart/index',
        name: 'MonthlyOutputChart',
        meta: { title: '车间时间范围产量报表' }
      }
    ]
  },
  {
    path: '/productline-monitor',
    alwaysShow: true,
    component: Layout,
    meta: { title: '产线监控', icon: 'clipboard' },
    children: [
      {
        path: 'line-monitor',
        component: () => import('@/views/productline-monitor/line-monitor/index'),
        url: '/productline-monitor/line-monitor/index',
        name: 'LineMonitor',
        meta: { title: '生产线监控', roles: ['admin'] }
      },
      {
        path: 'welding-workshop-monitor',
        component: () => import('@/views/productline-monitor/welding-workshop-monitor/index'),
        url: '/productline-monitor/welding-workshop-monitor/index',
        name: 'WeldingWorkshopMonitor',
        meta: { title: '焊装产线监控' }
      },
      {
        path: 'painting-workshop-monitor',
        component: () => import('@/views/productline-monitor/painting-workshop-monitor/index'),
        url: '/productline-monitor/painting-workshop-monitor/index',
        name: 'PaintingWorkshopMonitor',
        meta: { title: '涂装产线监控' }
      },
      {
        path: 'assemble-workshop-monitor',
        component: () => import('@/views/productline-monitor/assemble-workshop-monitor/index'),
        url: '/productline-monitor/assemble-workshop-monitor/index',
        name: 'AssembleWorkshopMonitor',
        meta: { title: '总装产线监控' }
      },
      {
        path: 'bdc-monitor',
        component: () => import('@/views/productline-monitor/bdc-monitor/index'),
        url: '/productline-monitor/bdc-monitor/index',
        name: 'BdcMonitor',
        meta: { title: 'BDC监控' }
      },
      {
        path: 'workshop-carbody-monitor',
        component: () => import('@/views/productline-monitor/workshop-carbody-monitor/index'),
        url: '/productline-monitor/workshop-carbody-monitor/index',
        name: 'WorkshopCarbodyMonitor',
        meta: { title: '车身数量监控' }
      },
      {
        path: 'pack-workshop-monitor',
        component: () => import('@/views/productline-monitor/pack-workshop-monitor/index'),
        url: '/productline-monitor/pack-workshop-monitor/index',
        name: 'PackWorkshopMonitor',
        meta: { title: 'PACK车间产线监控' }
      },
      {
        path: 'stamping-workshop-monitor',
        component: () => import('@/views/productline-monitor/stamping-workshop-monitor/index'),
        url: '/productline-monitor/stamping-workshop-monitor/index',
        name: 'StampingWorkshopMonitor',
        meta: { title: '冲压车间产线监控' }
      }
    ]
  },
  {
    path: '/vin-in-system',
    alwaysShow: true,
    component: Layout,
    meta: { title: '在制车', icon: 'zip' },
    children: [
      {
        path: 'welding-in-system',
        component: () => import('@/views/vin-in-system/welding-in-system/index'),
        url: '/vin-in-system/welding-in-system/index',
        name: 'WeldingInSystem',
        meta: { title: '焊装在制' }
      },
      {
        path: 'painting-in-system',
        component: () => import('@/views/vin-in-system/painting-in-system/index'),
        url: '/vin-in-system/painting-in-system/index',
        name: 'PaintingInSystem',
        meta: { title: '涂装在制' }
      },
      {
        path: 'assembly-in-system',
        component: () => import('@/views/vin-in-system/assembly-in-system/index'),
        url: '/vin-in-system/assembly-in-system/index',
        name: 'AssemblyInSystem',
        meta: { title: '总装在制' }
      },
      {
        path: 'bdc-in-system',
        component: () => import('@/views/vin-in-system/bdc-in-system/index'),
        url: '/vin-in-system/bdc-in-system/index',
        name: 'BDCInSystem',
        meta: { title: 'BDC在制' }
      }
    ]
  },
  {
    path: '/production',
    alwaysShow: true,
    component: Layout,
    meta: { title: '生产', icon: 'pdf' },
    children: [
      {
        path: 'production-daily',
        component: () => import('@/views/production/production-daily/index'),
        url: '/production/production-daily/index',
        name: 'ProductionDaily',
        meta: { title: '整车生产日报' }
      },
      {
        path: 'router-log-query',
        component: () => import('@/views/production/router-log-query/index'),
        url: '/production/router-log-query/index',
        name: 'RouterLogQuery',
        meta: { title: '整车过点查询' }
      },
      {
        path: 'vehicle-detail-query',
        component: () => import('@/views/production/vehicle-detail-query/index'),
        url: '/production/vehicle-detail-query/index',
        name: 'VehicleDetailQuery',
        meta: { title: '车辆细节查询' }
      },
      {
        path: 'stamping-daily',
        component: () => import('@/views/production/stamping-daily/index'),
        url: '/production/stamping-daily/index',
        name: 'StampingDaily',
        meta: { title: '冲压生产日报' }
      },
      {
        path: 'stamping-report-query',
        component: () => import('@/views/production/stamping-report-query/index'),
        url: '/production/stamping-report-query/index',
        name: 'StampingReportQuery',
        meta: { title: '冲压报交查询' }
      }
    ]
  },
  {
    path: '/PMC',
    alwaysShow: true,
    component: Layout,
    meta: { title: 'PMC', icon: 'guide' },
    children: [
      {
        path: 'welding-monitor',
        component: () => import('@/views/PMC/welding-monitor/index'),
        url: '/PMC/welding-monitor/index',
        name: 'WeldingMonitor',
        meta: { title: '焊装实况' }
      },
      {
        path: 'assembly-monitor',
        component: () => import('@/views/PMC/assembly-monitor/index'),
        url: '/PMC/assembly-monitor/index',
        name: 'AssemblyMonitor',
        meta: { title: '总装实况' }
      }
    ]
  },
  { path: '/keyparts-scan', url: '/mes-web/keyparts-scan/index', component: () => import('@/views/mes-web/keyparts-scan/index'), hidden: true },
  { path: '/reviewparts-scan', url: '/mes-web/reviewparts-scan/index', component: () => import('@/views/mes-web/reviewparts-scan/index'), hidden: true },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true },
  
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
